package com.example.boardstandardactivity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.View;

import com.example.boardstandardactivity.stardardReceiver.standardReceiver;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private standardReceiver standardReceiver;
    public final String STANDARD_ACTION = "broadTest";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        findViewById(R.id.button).setOnClickListener(this);
    }

    /**
     * Called when a view has been clicked.
     *
     * @param v The view that was clicked.
     */
    @Override
    public void onClick(View v) {
        Intent  intent = new Intent("STANDARD_ACTION");
        sendBroadcast(intent);
    }

    @Override
    protected void onStart() {
        super.onStart();
        standardReceiver = new standardReceiver();
        IntentFilter filter = new IntentFilter("STANDARD_ACTION");
        registerReceiver(standardReceiver,filter);
    }

    @Override
    protected void onStop() {
        super.onStop();
        unregisterReceiver(standardReceiver);
    }
}